# 交集 a & b
# 并集 a | b
# 差集 a - b ，表示a中去掉b中有的结果进行显示


# 需要推送的城市
states_needed = set(["mt", "wa", "or", "id", "nv", "ut", "ca", "az"])
stations = {}
# 不同电台能覆盖的城市
stations["kone"] = set(["id", "nv", "ut"])
stations["ktwo"] = set(["wa", "id", "mt"])
stations["kthree"] = set(["or", "nv", "ca"])
stations["kfour"] = set(["nv", "ut"])
stations["kfive"] = set(["ca", "az"])

# 最后选择的电台初始化为空集合
final_stations = set()

for station, states_for_station in stations.items():  # 电台，电台覆盖的城市
    # 选择的电台已覆盖的城市，初始化为空集合
    # 选择的电台初始化为None
    best_station = None
    states_covered = set()
    covered = states_needed & states_for_station  # 取交集
    if len(covered) > len(states_covered):  # 如果需要覆盖的城市>电台已覆盖的城市
        best_station = station  # 当前的电台
        states_covered = covered  # 当前电台覆盖的城市
        states_needed -= states_covered
        final_stations.add(best_station)
#
# while states_needed:
#     best_station = None
#     states_covered = set()
#     for station, states in stations.items():
#         covered = states_needed & states
#         if len(covered) > len(states_covered):
#             best_station = station
#             states_covered = covered
#     states_needed -= states_covered
#     final_stations.add(best_station)

print(final_stations)
